OS_NAME := $(shell uname -s)

ifeq ($(OS_NAME),Linux)
	os = linux
else ifeq ($(OS_NAME),Darwin)
	os = macos
else
	os = windows
endif


targets=test_conf   \
		test_data   \
		test_client \
		test_detect \
		test_log
cxx=g++
args=-std=c++17 -ljsoncpp
conf=cloud.json

ifeq ($(os),macos)
    args += -framework CoreFoundation -framework CoreServices
endif

.PHONY:all clean

all: $(targets) $(conf)

test_conf:test_conf.cc
	$(cxx) -o $@ $^ $(args)

test_data:test_data.cc
	$(cxx) -o $@ $^ $(args)

test_client:test_client.cc
	$(cxx) -o $@ $^ $(args)

test_detect:test_detect.cc
	$(cxx) -o $@ $^ $(args)

test_log:test_log.cc
	$(cxx) -o $@ $^ $(args)

$(conf):../$(conf)
	ln -s $^ $@

clean:
	rm -rf $(targets) $(conf)
